<template>
	<view class="rectificationContent">
		<commonNavBar title="查看更多"  ></commonNavBar>   
		 <view class="centre" style="margin-top: 150rpx;">
		 	<z-paging ref="paging" autowire-list-name="robotList"  default-page-no="0" style="margin-top: 150rpx;" autowire-query-name="listData"  :created-reload="false" :auto="false"  >
			  <uni-list class="robotList"> 
					<uni-list-item   v-for="(m,index) in robotList" class="list-item"  :showArrow="true" :title="removeBetweenAtSymbols(m.problemAbstract)" :clickable="false"  link="navigateTo"
						 @tap="showInfo(m.problemResult,m.problemAbstract,m.id,m.detailType)"  
					/> 
			  </uni-list>
		    </z-paging>
	    </view>
	</view>
</template>

<script>
	import commonNavBar from '@/components/CommonNavBar.vue';
	
	export default {
		components:{
			commonNavBar
		},
		data() {
			return { 
				inputValue:'', 
				tableName:'', 
				companyId:null, 
				robotList:[]
			}
		},
		onLoad(details) {
			const that = this; 
			const eventChannel = this.getOpenerEventChannel();  
			eventChannel.on('loadData', function(data) {
				that.inputValue = data.content
				that.tableName = data.tableName
				that.companyId = data.companyId
				console.log(that.inputValue)
				console.log(that.tableName) 
				console.log(that.companyId)
				that.$refs.paging.reload();
			})
		
		}, 
		methods: {
			goBack:function(){
				uni.navigateBack();
			},
			async listData(pageNum,pageSize){
				const res = await uni.$api.commentLabelGetResult({
					message: this.inputValue,
					tableName: this.tableName,
					companyId: this.companyId,
					pageNum: pageNum,
					pageSize: pageSize,
				}); 
				this.$refs.paging.complete(res.data.data);
			},
			showInfo(problemResult,problemAbstract,id,detailType) {  
				//查看消息详情信息
				if(detailType == 'text'){
					uni.navigateTo({
						url:'/pages/robot/messageInfo',
						success: (res) => {
							res.eventChannel.emit('updatePageData',{ data:'', title: problemAbstract ,content: problemResult })
						}
					})
				} else if(detailType == 'page'){
					//提取消息跳转页面 截取两个@@之间的跳转路径信息
					let  pagePath = this.extractBetweenAtSymbols(problemResult);
					console.log("pagePath",pagePath);
					uni.navigateTo({
						url: pagePath + '&detail=true' 
					})
				}
			},
			extractBetweenAtSymbols(str) {
				if(str == null ){
					return str;
				}
			    const match = str.match(/@(.*?)@/);
			    return match ? match[1] : str;
			},
			removeBetweenAtSymbols(str) {
				if(str == null ){
					return str;
				} 
			    return str.replace(/@.*?@/g, '');
			}
		}
	}
</script>

<style lang="scss">
.rectificationContent {
		background: #F9F9F9;
		height: calc(100vh - 195rpx);
		width: 750rpx;
		
		.upper {
			position: fixed;
			z-index: 1;
			top: 0;
			left: 0;
			width: 100%;

			.title {
				background: url('/static/img/inspectBg.png');
				background-size: cover;
				width: 100%;
				height: 115rpx;
				line-height: 115rpx;
				position: relative;
				display: flex;
				justify-content: center;

				.arrow {
					position: absolute;
					left: 33rpx;
					top: 50%;
					transform: translate(0%, -50%);
					width: 100rpx;
					height: 100rpx;
					 
					&::before {
						display: block;
						content: "";
						position: absolute;
						top: 50%;
						left: 0%;
						width: 20rpx;
						height: 20rpx;
						border-left: 1px solid #fff;
						border-top: 1px solid #fff;
						transform: translate(0%, -50%) rotate(-45deg);
					}
				}

				text {
					font-size: 30rpx;
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: 500;
					color: #FFFFFF;
					letter-spacing: 1px;
				}
			}
		}
}
 
	.centre { 
			padding: 125rpx 17.5rpx 0 17.5rpx;
			height: calc(100vh - 280rpx);
			overflow-x: hidden;
			display: flex;
			flex-direction: column;
			 
		}
		.list-item{ 
			padding: 10rpx 0px;
		}
</style>
